package fnord.jovian.tango;

import java.util.Vector;

import fnord.illuminati.order.AttackType;
import fnord.jovian.TheBoard;
import fnord.jovian.tango.TheAssemblyLayout.TheAssemblyOrientation;

public class TheAttackMenu extends TheMenu {


	public TheAttackMenu(TheBoard board) {
		super(300, 250, board);
		_mask = null;
		TheAssemblyLayout layout = new TheAssemblyLayout(TheAssemblyOrientation.VERTICAL);
		setTheLayout(layout);
		showNeutral(true);
	}

	private class TheAttackListener implements TheListener {

		AttackType _type;

		public TheAttackListener(AttackType type) {
			_type = type;
		}

		public void doAction() {
			_board.sendAttack(_type);
		}
	}

	private class TheControlListener implements TheListener {
		public void doAction() {
			_board.showControl();
		}
	}

	private class TheCancelListener implements TheListener {
		public void doAction() {
			_board.cancelAction();
		}
	}

	public void showNeutral(boolean show) {
		if (!show) {
			_objects = new Vector<TheObject>();
			this.addComponent(new TheButton("Destroy", 200, 30, new TheAttackListener(AttackType.DESTROY)));
			this.addComponent(new TheButton("Control", 200, 30, new TheControlListener()));
			this.addComponent(new TheButton("Cancel Attack", 200, 30, new TheCancelListener()));
		}
		else {
			_objects = new Vector<TheObject>();
			this.addComponent(new TheButton("Destroy", 200, 30, new TheAttackListener(AttackType.DESTROY)));
			this.addComponent(new TheButton("Neutralize", 200, 30, new TheAttackListener(AttackType.DESTROY)));
			this.addComponent(new TheButton("Control", 200, 30, new TheControlListener()));
			this.addComponent(new TheButton("Cancel Attack", 200, 30, new TheCancelListener()));
		}
	}

}
